class Person{
    name:string;
    age:number;
    constructor(name:string,age:number){
        this.name=name;
        this.age=age;
    }
    speak(){
        console.log(`我叫：${this.name},今年${this.age}岁`)
    }
}

// 属性的简写形式：
class Person1{
    constructor(public name:string,public age:number,private readonly grade:string){}
}

const p1=new Person('张三',18)
console.log(p1)
p1.speak()

class Student extends Person{ 
    grade:string;
    constructor(name:string,age:number,grade:string){
        super(name,age);
        this.grade=grade;
    }

    // 重写父类方法，最好加上override，可以获取提示
    override speak(): void {
        console.log("hi")
    }

    study(){
        console.log(`${this.name}努力学习中`)
    }
}

const s1=new Student('李同学',16,'高三')
s1.speak()
s1.study()